#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    bool evaluateTree(TreeNode* root)
    {
        if (root->left == nullptr) return root->val == 1 ? true : false;

        bool left = evaluateTree(root->left);
        bool right = evaluateTree(root->right);

        return root->val == 2 ? left | right : left & right;
    }
};